home *** CD-ROM | disk | FTP | other *** search
- /* GadTools layout toolkit
- **
- ** Copyright © 1993-1995 by Olaf `Olsen' Barthel
- ** Freely distributable.
- */
-
- #include "gtlayout_global.h"
-
- LONG __stdargs
- LT_GetAttributes(LayoutHandle *Handle,LONG ID,...)
- {
- va_list VarArgs;
- LONG Result;
-
- va_start(VarArgs,ID);
- Result = LT_GetAttributesA(Handle,ID,(struct TagItem *)VarArgs);
- va_end(VarArgs);
-
- return(Result);
- }
-
-
- /*****************************************************************************/
-
-
- LONG LIBENT
- LT_GetAttributesA(REG(a0) LayoutHandle *Handle,REG(d0) LONG ID,REG(a1) struct TagItem *TagList)
- {
- if(Handle)
- {
- struct TagItem *ThisTag;
- ObjectNode *Node = NULL;
-
- if(ThisTag = FindTagItem(LAPR_Gadget,TagList))
- Node = ((struct Gadget *)ThisTag -> ti_Data) -> UserData;
-
- if(!Node)
- {
- if(ThisTag = FindTagItem(LAPR_Object,TagList))
- Node = (ObjectNode *)ThisTag -> ti_Data;
- }
-
- if(!Node)
- Node = LTP_FindNode(Handle -> TopGroup,ID);
-
- if(Node)
- {
- if(TagList)
- {
- struct TagItem *TagItem,
- *TempPtr = TagList;
- LONG *Value;
-
- while(TagItem = NextTagItem(&TempPtr))
- {
- Value = (LONG *)TagItem -> ti_Data;
-
- switch(TagItem -> ti_Tag)
- {
- case LA_Left:
-
- if(Node -> Type == FRAME_KIND && Node -> Special . Frame . DrawBox)
- *Value = Node -> Left + 4;
- else
- *Value = Node -> Left;
-
- break;
-
- case LA_Top:
-
- if(Node -> Type == FRAME_KIND && Node -> Special . Frame . DrawBox)
- *Value = Node -> Top + 2;
- else
- *Value = Node -> Top;
-
- break;
-
- case LA_Width:
-
- if(Node -> Type == FRAME_KIND && Node -> Special . Frame . DrawBox)
- *Value = Node -> Width - 8;
- else
- *Value = Node -> Width;
-
- break;
-
- case LA_Height:
-
- if(Node -> Type == FRAME_KIND && Node -> Special . Frame . DrawBox)
- *Value = Node -> Height - 4;
- else
- *Value = Node -> Height;
-
- break;
-
- #ifdef DO_BOOPSI_KIND
- case LABO_Object:
-
- if(Node -> Type == BOOPSI_KIND)
- *Value = (LONG)Node -> Host;
- else
- *Value = NULL;
-
- break;
- #endif /* DO_BOOPSI_KIND */
- case LA_Chars:
-
- *Value = Node -> Chars;
- break;
-
- case LA_Lines:
-
- *Value = Node -> Lines;
- break;
-
- case LA_LabelLeft:
-
- switch(Node -> LabelPlace)
- {
- case PLACE_LEFT:
-
- *Value = Node -> Left - (INTERWIDTH + Node -> LabelWidth);
- break;
-
- case PLACE_RIGHT:
-
- *Value = Node -> Left + Node -> Width + INTERWIDTH;
- break;
-
- case PLACE_ABOVE:
-
- *Value = Node -> Left + (Node -> Width - Node -> LabelWidth) / 2;
- break;
-
- case PLACE_BELOW:
-
- *Value = Node -> Left + (Node -> Width - Node -> LabelWidth) / 2;
- break;
-
- case PLACE_IN:
-
- *Value = Node -> Left + (Node -> Width - Node -> LabelWidth) / 2;
- break;
- }
-
- break;
-
- case LA_LabelTop:
-
- switch(Node -> LabelPlace)
- {
- case PLACE_LEFT:
-
- *Value = Node -> Top + (Node -> Height - Handle -> RPort . TxHeight) / 2;
- break;
-
- case PLACE_RIGHT:
-
- *Value = Node -> Top + (Node -> Height - Handle -> RPort . TxHeight) / 2;
- break;
-
- case PLACE_ABOVE:
-
- *Value = Node -> Top - (Handle -> RPort . TxHeight + INTERHEIGHT);
- break;
-
- case PLACE_BELOW:
-
- *Value = Node -> Top + Node -> Height + INTERHEIGHT;
- break;
-
- case PLACE_IN:
-
- *Value = Node -> Top + (Node -> Height - Handle -> RPort . TxHeight) / 2;
- break;
- }
-
- break;
- }
- }
- }
-
- if(Node -> Host)
- {
- struct Gadget *Gadget = Node -> Host;
-
- switch(Node -> Type)
- {
- case CHECKBOX_KIND:
- case LISTVIEW_KIND:
- case MX_KIND:
- case CYCLE_KIND:
- case PALETTE_KIND:
- case SLIDER_KIND:
- case SCROLLER_KIND:
- #if defined(DO_POPUP_KIND) && defined(DO_BOOPSI_KIND)
- case POPUP_KIND:
- #endif
- #if defined(DO_TAB_KIND) && defined(DO_BOOPSI_KIND)
- case TAB_KIND:
- #endif
- #ifdef DO_GAUGE_KIND
- case GAUGE_KIND:
- #endif
- #ifdef DO_TAPEDECK_KIND
- case TAPEDECK_KIND:
- #endif /* DO_TAPEDECK_KIND */
- return(Node -> Current);
- #ifdef DO_BOOPSI_KIND
- case BOOPSI_KIND:
- {
- ULONG Storage;
-
- if(GetAttr(Node -> Special . BOOPSI . TagCurrent,Node -> Host,&Storage))
- return((LONG)Storage);
- else
- return(NULL);
- }
- #endif /* DO_BOOPSI_KIND */
-
- case VERTICAL_KIND:
- case HORIZONTAL_KIND:
-
- return((LONG)Node -> Special . Group . ActivePage);
-
- #ifdef DO_FRACTION_KIND
- case FRACTION_KIND:
- {
- STRPTR String;
-
- if(Gadget)
- String = ((struct StringInfo *)Gadget -> SpecialInfo) -> Buffer;
- else
- String = Node -> Special . String . String;
-
- if(String)
- {
- FIXED Contents;
-
- Contents = LT_String2Fixed(String);
-
- if(Contents < Node -> Min)
- Contents = Node -> Min;
- else
- {
- if(Contents > Node -> Max)
- Contents = Node -> Max;
- }
-
- LT_SetAttributes(Handle,Gadget -> GadgetID,LAFC_Number,Contents,TAG_DONE);
-
- return((LONG)Contents);
- }
- }
- break;
- #endif
-
- #ifdef DO_LEVEL_KIND
- case LEVEL_KIND:
-
- return(Node -> Special . Level . Level);
- #endif /* DO_LEVEL_KIND */
- case STRING_KIND:
-
- if(Gadget)
- {
- struct StringInfo *StringInfo;
-
- StringInfo = (struct StringInfo *)Gadget -> SpecialInfo;
-
- return((LONG)StringInfo -> Buffer);
- }
- else
- {
- STRPTR String = Node -> Special . String . String;
-
- if(String)
- return((LONG)String);
- else
- return((LONG)"");
- }
-
- break;
- #ifdef DO_PASSWORD_KIND
- case PASSWORD_KIND:
-
- return((LONG)Node -> Special . String . Original);
-
- break;
- #endif
- case INTEGER_KIND:
-
- if(Gadget)
- {
- struct StringInfo *StringInfo;
- LONG Contents;
-
- StringInfo = (struct StringInfo *)Gadget -> SpecialInfo;
-
- Contents = StringInfo -> LongInt;
-
- if(Contents < Node -> Min)
- Contents = Node -> Min;
- else
- {
- if(Contents > Node -> Max)
- Contents = Node -> Max;
- }
-
- LT_SetAttributes(Handle,Gadget -> GadgetID,
- GTIN_Number,Contents,
- TAG_DONE);
-
- return(Contents);
- }
- else
- return(Node -> Current);
-
- break;
-
- case GROUP_KIND:
-
- return((LONG)Node -> Special . Group . ActivePage);
- }
- }
- }
- else
- return((LONG)Handle -> UserData);
- }
-
- return(NULL);
- }
-